clear			all
set 			more off
cd				"~/Dropbox/Wina Migration/Wina's thesis TB's version/"
/*******************************************************************************
				Employment
********************************************************************************/
use				"Data/Merged", clear
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

foreach 		var in emp native_emp mig_emp_o mig_emp_n {
replace			prop_`var' = prop_`var' * 100
}
/*******************************************************************************
				Conventional shift-share instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_1.xlsx", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_1.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC//Employment_1.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_1.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Shift-share instrument with 10-year lag
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_2.xlsx", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_2.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_2.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC//Employment_2.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Multiple lag instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_3.xlsx", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_3.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_3.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)

ivreg2			prop_mig_emp_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/EDCC/Employment_3.xlsx", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
